﻿package  com.devilcat.ws{
	import com.devilcat.ws.Basicws;
	import com.worlize.websocket.*;
	import com.devilcat.dt.Gamedt;
	
	public class PlayerInforws extends Basicws{
		public var fc:Function;
		public function PlayerInforws() {
			super("iw-protocol");
			// constructor code
		}
		override function handleWebSocketOpen(event:WebSocketEvent):void
		{
		}
		public function GetInfor(_uid:int,_infor:String,_fc:Function){
			fc=_fc;			
			var pack:Object = new Object();
			pack.uid=_uid;
			pack.action="loadplayerinfor";
			pack.playerinfor=_infor;
			var myJson:String = JSONString(pack);
			websocket.sendUTF(myJson);
			
		}
		override function handleWebSocketMessage(event:WebSocketEvent):void
		{
			if (event.message.type === WebSocketMessage.TYPE_UTF8)
			{	
				debug(event.message.utf8Data);
				fc(JSONObject(event.message.utf8Data));
				//trace("PlayerInforws: " + event.message.utf8Data);
			}
		}

	}
	
}
